//菜单管理模块的接口
import request from '@/utils/request'
import type { PermissionResponseData, MenuParams } from './type'

enum API {
    //获取全部菜单与按钮的标识数据的接口
    ALLPERMISSION_URL = 'admin/acl/permission',
    //给某一级菜单新增一个子菜单的接口
    ADDMENU_URL = 'admin/acl/permission/save',
    //更新某一个已有菜单的接口
    UPDATEMENU_URL = 'admin/acl/permission/update',
    //删除已有菜单的接口
    DELETEMENU_URL = 'admin/acl/permission/remove/'
}

//获取全部菜单与按钮的标识数据的接口方法
export const reqAllPermission = () => request.get<any, PermissionResponseData>(API.ALLPERMISSION_URL)
//添加与更新菜单的接口方法
export const reqAddOrUpdatePermission = (data: MenuParams) => {
    if (data.id) {
        return request.put<any, any>(API.UPDATEMENU_URL, data)
    } else {
        return request.post<any, any>(API.ADDMENU_URL, data)
    }
}
//删除已有菜单的接口方法
export const reqDeleteMenu = (id: number) => request.delete<any, any>(API.DELETEMENU_URL + id)